Code instrumentation is a method for analyzing and evaluating program code performance. During this process, new instructions (or probe code) are added to the program, and, consequently, the original code in the program is changed and/or relocated, resulting in modified or instrumented code. Some examples of probe code include adding values to a register, moving the content of one register to another register, moving the address of some data to some registers, etc. Code instrumentation may be statically or dynamically executed by an instrumentor, which, typically, is also a program.
A debugger is a program assisting a programmer to find “bugs” or errors in other programs. A debugger allows the programmer to stop at breakpoints for performing debugging functions. Usually, the programmer examines and changes the value of the program variables, redirects the program flow, single steps the program, etc. Most operating systems support a debugger interface for the programmer to interact with the debugger.
Currently, an instrumentor and a debugger may not work together effectively. For example, an operating system may not allow an instrumentor and a debugger to concurrently control the debugger interface. A debugger may not be able to handle code that has been manipulated or relocated by dynamic code instrumentation. A traditional debugger may not allow setting breakpoints in a non-text segment in the instrumented code. Disassembling code during code debugging in shared memory may cause memory faults. Using breakpoints for both dynamic instrumentation and debugging may be conflicting.
Based on the foregoing, it is clearly desirable that mechanisms be provided to solve the above deficiencies and associated problems.